﻿using fuzhu;
using SqlSugar;
using U8COWeb;
using XXX.Bo;
using XXX.Common;
using XXX.Models;
using XXX.Models.AS;
using ZDEntity;

namespace Yonyou.U8.BO
{
    /// <summary>
    ///不能直接继承，因为调用co时，根据AS_Department类直接转换
    /// </summary>
    public class RdStyleVM
    {
        //当前的数据库连接字符串
        public string conStr { get; set; }
        public string xmlConfig { get; set; }
        public static string cDatabase = "";

        public Rd_Style entity { get; set; }

        public RdStyleVM()
        {
            //conStr
            conStr = CanShu.conStr;
            //初始化定义xmlconfig
            xmlConfig = XmlOperation.GetConfigXML();
        }



        /// <summary>
        /// 读取收发类别信息
        /// </summary>
        /// <param name="irdflag">收发类别方向，1 入库，0 出库</param>
        /// <returns></returns>
        public RetModel2 GetEndList(int irdflag)
        {
            try
            {
                using (SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
                {
                    ConnectionString = conStr,
                    DbType = SqlSugar.DbType.SqlServer,
                    IsAutoCloseConnection = true
                }))
                {

                    List<Rd_Style> lst = db.Queryable<Rd_Style>().Where(x => (x.bRdFlag== irdflag && x.bRdEnd)).ToList();
                    if (lst != null)
                    { 
                        return DBService.ReOKObject(lst); 
                    }
                    else
                    {
                        return DBService.ReErrObject("查询不到收发类别！");
                    }
                }
            }
            catch (Exception ex)
            {
                return DBService.ReErrObject(ex.Message);
            }

        }
    }
}
